home *** CD-ROM | disk | FTP | other *** search
- #include "bar.h"
- #include "xampids.h"
- #include <listbox.h>
- #include <bitover.h>
- #include <nradio.h>
- #include <ccheck.h>
- #include <extras.h>
- #include <stdlib.h>
-
- #define NF_Message WM_USER + 5
- class TCustXAmp : public TApplication
- {
- CustColors Colors;
- CustCursors Cursors;
- public:
- TCustXAmp(LPSTR AName, HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpCmdLine, int nCmdShow)
- : TApplication(AName, hInstance, hPrevInstance, lpCmdLine, nCmdShow) {};
- virtual void InitMainWindow();
- };
-
- class TTellParent : public TCustomWindow
- {
- int NMsg, Id;
- public:
- TTellParent(PTWindowsObject AParent, LPSTR ATitle,
- PCustColors Colors, PCustCursors ACursors,
- int NotifMessage, int AnId)
- : TCustomWindow(AParent, ATitle, Colors,ACursors),
- TUnderlying(Colors, ACursors)
- { NMsg = NotifMessage;
- Id = AnId; };
- ~TTellParent() { };
- virtual void WMClose(RTMessage Msg) = [WM_FIRST + WM_CLOSE]
- { Chars.Closing = TRUE;
- SendMessage(Parent->HWindow, NMsg, Id, 0l); };
- };
-
- // Declare TMainWindow, a TDialog descendant
- class TMainWindow : public TBarDialog, public TBitOver
- {
- PTListBox List;
- TTellParent* ChildWind;
- char IsWind;
- HINSTANCE Data;
- PTNCCharButton NCBtns[2];
- PTNCRadioButton NCRadios[2];
- PTCRadio TheRadio;
- PTCCheck TheCheck;
- public:
- TMainWindow(PTWindowsObject AParent, LPSTR AName,
- PCustColors AColors, PCustCursors ACursors);
- ~TMainWindow();
-
- virtual void Window(RTMessage) = [ID_FIRST + ID_WINDOW];
- virtual void Nofication(RTMessage Msg) = [NF_Message]
- { delete ChildWind;
- IsWind = FALSE; };
- virtual void SetupWindow();
-
- virtual void NCButton1(RTMessage) = [ID_FIRST + ID_NCBUTTON + 0];
- virtual void NCButton2(RTMessage) = [ID_FIRST + ID_NCBUTTON + 1];
- virtual void NCRadio(RTMessage) = [ID_FIRST + ID_NCBUTTON + 2];
-
- virtual void WMTimer(RTMessage) = [WM_FIRST + WM_TIMER];
- };
-
- void TCustXAmp::InitMainWindow()
- {
- //The Custom windows classes take a copy of the
- //specified colors and cursors
- Colors.OrigClassDefaults();
- Colors.StaticText = RGB(0,255,255);
- Colors.TitleBarActive = GetSysColor(COLOR_ACTIVECAPTION);
- Colors.TitleBarInactive = GetSysColor(COLOR_INACTIVECAPTION);
-
- Cursors.OrigClassDefaults();
- MainWindow = new TMainWindow(NULL, "XAMP_DLG",
- &Colors, &Cursors);
- }
-
- TMainWindow::TMainWindow(PTWindowsObject AParent, LPSTR AName,
- PCustColors AColors, PCustCursors ACursors)
- : TBarDialog(AParent, AName, AColors, ACursors),
- TUnderlying(AColors, ACursors)
- {
- List = new TListBox(this, ID_LISTBOX);
- TheRadio = new TCRadio(this, 104, NULL);
- TheCheck = new TCCheck(this, 105, NULL);
-
- Data = GetCustWindInstance();
- SetBitmap(Data, "BACK_BRICK");
- }
-
-
- TMainWindow::~TMainWindow()
- {
- DeleteExtendedButtons();
-
- KillTimer(HWindow, 0);
-
- delete TheRadio;
- delete TheCheck;
-
- delete List;
- if(IsWind) delete ChildWind;
-
- for(int i=0;i<2;i++)
- {
- delete NCBtns[i];
- delete NCRadios[i];
- }
- }
-
- void TMainWindow::SetupWindow()
- {
- TCustomDialog::SetupWindow();
- AddExtendedButtons(Data,1);
-
- RECT ARect;
- char BText[8];
-
- for(int i=0;i<2;i++)
- {
- AreaFromTopLeft(ARect,i+1);
-
- wsprintf(BText,"%c",'1'+i);
- NCBtns[i] = new TNCCharButton(HWindow, ARect,
- ID_NCBUTTON + i,Data, BText);
- AddNCButton(NCBtns[i]);
- }
- for(i=2;i<4;i++)
- {
- AreaFromTopLeft(ARect,i+1);
-
- switch(i)
- {
- case 2:
- NCRadios[i-2] = new TNCRadioButton(HWindow, ARect,
- ID_NCBUTTON + i,Data, "CHK_BLUELIGHT",
- "CHK_BLUEOFF", TRUE, TRUE);
- break;
- case 3:
- NCRadios[i-2] = new TNCRadioButton(HWindow, ARect,
- ID_NCBUTTON + i,Data, "CHK_GREENLIGHT",
- "CHK_GREENOFF", FALSE, TRUE);
- break;
- }
-
- AddNCButton(NCRadios[i-2]);
- }
-
- GetModule()->MakeWindow(List);
-
- char Text[40];
- for(i=0;i<20;i++)
- {
- wsprintf(Text,"Line %d",i);
- List->AddString(Text);
- }
-
- SetTimer(HWindow, 0, 500, NULL);
- }
-
- void TMainWindow::WMTimer(RTMessage)
- {
- NCRadios[1]->SetState(!NCRadios[1]->GetState());
- DrawNCButton(ID_NCBUTTON + 3);
- }
-
- void TMainWindow::Window(RTMessage)
- {
- if(IsWind)
- delete ChildWind;
-
- CustColors Colors;
- Colors.WindowsDefaults();
-
- CustCursors Cursors;
- Cursors.OrigClassDefaults();
-
- ChildWind = new TTellParent(this,
- "Custom Window Test", &Colors, &Cursors,
- NF_Message, 201);
- ChildWind->Attr.Style = WS_POPUP | WS_BORDER |
- WS_CAPTION | WS_VISIBLE | WS_SYSMENU |
- WS_MINIMIZEBOX | WS_THICKFRAME;
- ChildWind->Attr.W = 250;
- ChildWind->Attr.H = 100;
-
- GetModule()->MakeWindow(ChildWind);
-
- IsWind = TRUE;
- }
-
- //Windows Entry Point
- int PASCAL WinMain(HINSTANCE hInstance,
- HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
- {
- TCustXAmp ACustXAmp("",hInstance, hPrevInstance,
- lpCmdLine, nCmdShow);
- ACustXAmp.Run();
-
- return ACustXAmp.Status;
- }
-
- void TMainWindow::NCButton1(RTMessage)
- {
- char Text[1000];
-
- wsprintf(Text,"Size of TUnderlying: %d\n\r"
- "Size with TBitOver: %d\n\r"
- "Size of TNCButton: %d\n\r",
- sizeof(TUnderlying),sizeof(TBitOver),
- sizeof(TNCButton));
-
- CMessageBox(this, Text,
- "Information Window",
- MB_OK | MB_ICONINFORMATION,
- GetCustWindModule());
- }
-
- void TMainWindow::NCButton2(RTMessage)
- {
- const char RegularBits[3][20] = {"BACK_FISH",
- "BACK_BRICK", "BACK_SPOTWARE" };
- const char MessageBits[4][20] = {"BACK_INFORMATION",
- "BACK_QUESTION", "BACK_EXCLAMATION",
- "BACK_STOP"};
-
- if(NCRadios[0]->GetState())
- SetBitmap(Data, (LPSTR)MessageBits[random(4)]);
- else
- SetBitmap(Data, (LPSTR)RegularBits[random(3)]);
-
- InvalidateRect(HWindow, NULL, TRUE);
- }
-
- void TMainWindow::NCRadio(RTMessage)
- {
- }
-
-